# -*- coding: utf-8 -*-
# @Time    : 2024/2/4 21:32
# @Author  : micah
# @File    : 19.动作链.py
# @Software: PyCharm
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains  # 拖拽


browser = webdriver.Chrome()
url = 'https://www.runoob.com/try/try.php?filename=jqueryui-api-droppable'
browser.get(url)

log = browser.find_element(By.XPATH, '//div[@id="iframewrapper"]/iframe')
browser.switch_to.frame(log)

source = browser.find_element(By.CSS_SELECTOR, '#draggable')
target = browser.find_element(By.CSS_SELECTOR, '#droppable')

# 创建动作链对象
actions = ActionChains(browser)
actions.drag_and_drop(source, target).perform()

# 执行
# actions.perform()

time.sleep(3)
browser.quit()
